<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

$DB = JFX::registry('db');

$CONFIG = JFX::registry('config');

$this->ThrowConfigExceptions = false;

$dirname = dirname(__FILE__);
$dirname = str_replace(DIRECTORY_SEPARATOR, '/', $dirname);



// backup our existing data

/*
// mysql commands
if($DB->countRows($CONFIG->dbprefix.'iusers', '1=1')>0){
    if(file_exists($dirname.'/bup_users.sql')) unlink($dirname.'/bup_users.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_users.txt' FROM {$CONFIG->dbprefix}iusers");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_groups', '1=1')>0){
    if(file_exists($dirname.'/bup_groups.sql')) unlink($dirname.'/bup_groups.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_groups.txt' FROM {$CONFIG->dbprefix}iusers_groups");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_to_groups', '1=1')>0){
    if(file_exists($dirname.'/bup_users_to_groups.sql')) unlink($dirname.'/bup_users_to_groups.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_users_to_groups.txt' FROM {$CONFIG->dbprefix}iusers_to_groups");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_pages_to_groups', '1=1')>0){
    if(file_exists($dirname.'/bup_users_to_groups.sql')) unlink($dirname.'/bup_users_to_groups.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_pages_to_groups.txt' FROM {$CONFIG->dbprefix}iusers_pages_to_groups");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_history', '1=1')>0){
    if(file_exists($dirname.'/bup_history.sql')) unlink($dirname.'/bup_history.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_history.txt' FROM {$CONFIG->dbprefix}iusers_history");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_config', '1=1')>0){
    if(file_exists($dirname.'/bup_config.sql')) unlink($dirname.'/bup_config.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_config.txt' FROM {$CONFIG->dbprefix}iusers_config");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_countries', '1=1')>0){
    if(file_exists($dirname.'/bup_countries.sql')) unlink($dirname.'/bup_countries.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_countries.txt' FROM {$CONFIG->dbprefix}iusers_countries");
};
if($DB->countRows($CONFIG->dbprefix.'iusers_cities', '1=1')>0){
    if(file_exists($dirname.'/bup_cities.sql')) unlink($dirname.'/bup_cities.sql');
    $DB->query("SELECT * INTO OUTFILE '{$dirname}/bup_cities.txt' FROM {$CONFIG->dbprefix}iusers_cities");
};
// end of mysql statements

*/

$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_groups');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_pages_to_groups');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_to_groups');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_history');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_config');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_countries');
$DB->query('DROP TABLE IF EXISTS '.$CONFIG->dbprefix.'iusers_cities');

$this->RemovePermission('perm_config');
$this->RemovePermission('perm_users');
$this->RemovePermission('perm_groups');
$this->RemovePermission('perm_places');


